package io.nio;

import framework.AbstractTest;
import utils.Log;
import utils.StringUtils;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;
import java.nio.charset.Charset;
import java.util.Iterator;
import java.util.SortedMap;

/**
 * Created by shane on 2018/5/20.
 *
 */
public class AvailableCharsets extends AbstractTest {
    protected static final String TAG = AvailableCharsets.class.getName();

    @Override
    public void test(String[] args) {
        super.test(args);

        SortedMap<String, Charset> charsets = Charset.availableCharsets();
        Iterator<String> it = charsets.keySet().iterator();
        while (it.hasNext()) {
            String csName = it.next();
            Log.vn(csName);
            Iterator<String> aliases = charsets.get(csName).aliases().iterator();
            if(aliases.hasNext()) {
                Log.v(": ");
            }
            while (aliases.hasNext()) {
                Log.vn(aliases.next());
                if (aliases.hasNext()) {
                    Log.vn(", ");
                }
            }
        }
    }

    @Override
    protected String getTag() {
        return TAG;
    }

}
